package com.xc.service;

import com.github.pagehelper.PageInfo;
import com.xc.common.ServerResponse;
import com.xc.pojo.UserPosition;
import com.xc.vo.position.PositionVO;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author mipha
 * @version 1.0
 * @date 2019/2/16 3:04 PM
 */
public interface IUserPositionService {


    //  下单
    ServerResponse buy(Integer stockId , Integer buyNum
            , Integer buyType , Integer lever ,HttpServletRequest request ) throws Exception;

    //  平仓
    ServerResponse sell(String positionSn , int doType) throws Exception;

    //  锁仓
    ServerResponse lock(Integer positionId , Integer state , String lockMsg);

    //  删除
    ServerResponse del(Integer positionId);

    //  查询用户持仓单
    ServerResponse<PageInfo> findMyPositionByCodeAndSpell(String stockCode, String stockSpell
            , Integer state, HttpServletRequest request, int pageNum, int pageSize);

    /**
     *  查询用户所有持仓单的总盈亏
     *  循环每个持仓单，根据买涨买跌计算盈亏浮动
      */
    PositionVO findUserPositionAllProfitAndLose(Integer userId);


    //  查询用户 当前所有的持仓单
    List<UserPosition> findPositionByUserIdAndSellIdIsNull(Integer userId);


    /**
     *  代理
     */
    ServerResponse listByAgent(Integer positionType , Integer state , Integer userId
            , Integer agentId , String positionSn , String beginTime , String endTime
            , HttpServletRequest request , int pageNum , int pageSize);


    /**
     *  admin 后台
     */
    ServerResponse getIncome(Integer agentId,Integer positionType,String beginTime,String endTime);
    ServerResponse listByAdmin(Integer agentId,Integer positionType,Integer state
            ,Integer userId,String positionSn,String beginTime,String endTime,int pageNum,int pageSize);

    int CountPositionNum(Integer state,Integer accountType);
    BigDecimal CountPositionProfitAndLose();
    BigDecimal CountPositionAllProfitAndLose();


    /**
     *  定时任务
     *      收取留仓费
     *
     */
    void doClosingStayTask();
    ServerResponse closingStayTask(UserPosition position,Integer stayDays) throws Exception;

    //  查询有持仓单的用户id
    List<Integer> findDistinctUserIdList();





}
